package com.csf.controller;

import com.csf.annotation.Controller;
import com.csf.annotation.Autowired;
import com.csf.annotation.RequestMapping;
import com.csf.annotation.RequestParam;
import com.csf.service.MyService;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author chenshf
 */
@Controller
@RequestMapping("/hello")
public class HelloController {

	@Autowired("myService")
	private MyService myService;

 
	@RequestMapping("/sayHello")
	public void sayHello(HttpServletRequest request, HttpServletResponse response, @RequestParam(value = "name") String name) {
		try {
            PrintWriter writer = response.getWriter();
            writer.print(myService.hello(name));
            writer.flush();
            writer.close();
        } catch (IOException e) {
			e.printStackTrace();
		}
	}
}
